package com.tuanzi.loan.workflow.listener;

import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

/**
 * @author Ray
 * @date 2018/01/12
 */
@Component
public class ActivitiListenerInit implements ApplicationListener<ContextRefreshedEvent> {

	@Override
	public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
		if (contextRefreshedEvent.getApplicationContext().getParent() == null) { // root application context 没有parent，他就是老大.
			// 需要执行的逻辑代码，当spring容器初始化完成后就会执行该方法。
			BussinessEventListener bussinessEventListener = (BussinessEventListener) contextRefreshedEvent.getApplicationContext().getBean("bussinessEventListener");

			// 表单监听器
			// FormManageValidationListener formManageValidationListener =
			// (FormManageValidationListener) contextRefreshedEvent.getApplicationContext()
			// .getBean("formManageValidationListener");

			// bussinessEventListener.addWorkflowListener(formManageValidationListener);
		}
	}
}
